package com.example.nophase.service;

import android.content.Context;
import android.util.Log;

import com.igexin.sdk.GTIntentService;
import com.igexin.sdk.PushConsts;
import com.igexin.sdk.message.BindAliasCmdMessage;
import com.igexin.sdk.message.GTCmdMessage;
import com.igexin.sdk.message.GTNotificationMessage;
import com.igexin.sdk.message.GTTransmitMessage;

public class DemoIntentService extends GTIntentService {

    @Override
    public void onReceiveServicePid(Context context, int pid) {
    }

    // 处理透传消息
    @Override
    public void onReceiveMessageData(Context context, GTTransmitMessage msg) {
        // 透传消息的处理，详看 SDK demo
        Log.e(TAG, "onReceiveMessageData -> ");

    }

    // 接收 cid
    @Override
    public void onReceiveClientId(Context context, String clientid) {
        Log.e(TAG, "onReceiveClientId -> " + "clientid = " + clientid);
    }

    // cid 离线上线通知
    @Override
    public void onReceiveOnlineState(Context context, boolean online) {
    }

    // 各种事件处理回执
    @Override
    public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) {
        Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage);
        int action = cmdMessage.getAction();

        if (action == PushConsts.BIND_ALIAS_RESULT) {
            String sn = ((BindAliasCmdMessage) cmdMessage).getSn();
            String code = ((BindAliasCmdMessage) cmdMessage).getCode();
        /*  code 结果说明
            0：成功
            10099：SDK 未初始化成功
            30001：绑定别名失败，频率过快，两次调用的间隔需大于 5s
            30002：绑定别名失败，参数错误
            30003：绑定别名请求被过滤
            30004：绑定别名失败，未知异常
            30005：绑定别名时，cid 未获取到
            30006：绑定别名时，发生网络错误
            30007：别名无效
            30008：sn 无效 */
            Log.d(TAG, "bind alias result sn = " + sn + ", code = " + code);
        }
    }

    // 通知到达，只有个推通道下发的通知会回调此方法
    @Override
    public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) {
    }

    // 通知点击，只有个推通道下发的通知会回调此方法
    @Override
    public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) {
    }
}
